.class Lcom/htc/android/footprints/provider/FootprintsProvider$1;
.super Ljava/lang/Object;
.source "FootprintsProvider.java"

# interfaces
.implements Ljava/lang/Runnable;


# annotations
.annotation system Ldalvik/annotation/EnclosingClass;
    value = Lcom/htc/android/footprints/provider/FootprintsProvider;
.end annotation

.annotation system Ldalvik/annotation/InnerClass;
    accessFlags = 0x0
    name = null
.end annotation


# instance fields
.field final synthetic this$0:Lcom/htc/android/footprints/provider/FootprintsProvider;


# direct methods
.method constructor <init>(Lcom/htc/android/footprints/provider/FootprintsProvider;)V
    .locals 0
    .parameter

    .prologue
    .line 134
    iput-object p1, p0, Lcom/htc/android/footprints/provider/FootprintsProvider$1;->this$0:Lcom/htc/android/footprints/provider/FootprintsProvider;

    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    return-void
.end method


# virtual methods
.method public run()V
    .locals 15

    .prologue
    const/4 v11, 0x0

    const-string v14, "PRESET"

    const-string v13, "FootprintsProvider"

    .line 135
    iget-object v9, p0, Lcom/htc/android/footprints/provider/FootprintsProvider$1;->this$0:Lcom/htc/android/footprints/provider/FootprintsProvider;

    #getter for: Lcom/htc/android/footprints/provider/FootprintsProvider;->mContext:Landroid/content/Context;
    invoke-static {v9}, Lcom/htc/android/footprints/provider/FootprintsProvider;->access$000(Lcom/htc/android/footprints/provider/FootprintsProvider;)Landroid/content/Context;

    move-result-object v9

    const-string v10, "Footprints"

    invoke-virtual {v9, v10, v11}, Landroid/content/Context;->getSharedPreferences(Ljava/lang/String;I)Landroid/content/SharedPreferences;

    move-result-object v7

    .line 136
    .local v7, pref:Landroid/content/SharedPreferences;
    const-string v9, "PRESET"

    invoke-interface {v7, v14, v11}, Landroid/content/SharedPreferences;->getBoolean(Ljava/lang/String;Z)Z

    move-result v4

    .line 138
    .local v4, hasPreset:Z
    invoke-static {}, Lcom/htc/android/footprints/utils/FootprintUtils;->touchSDFile()V

    .line 139
    new-instance v1, Ljava/io/File;

    invoke-static {}, Lcom/htc/android/footprints/utils/FootprintUtils;->getDBPathOnSD()Ljava/lang/String;

    move-result-object v9

    invoke-direct {v1, v9}, Ljava/io/File;-><init>(Ljava/lang/String;)V

    .line 141
    .local v1, dbSDFile:Ljava/io/File;
    invoke-static {}, Lcom/htc/android/footprints/utils/StorageUtil;->hasExternalStorage()Z

    move-result v9

    if-nez v9, :cond_1

    .line 180
    :cond_0
    :goto_0
    return-void

    .line 142
    :cond_1
    invoke-virtual {v1}, Ljava/io/File;->exists()Z

    move-result v9

    if-eqz v9, :cond_2

    invoke-virtual {v1}, Ljava/io/File;->length()J

    move-result-wide v9

    const-wide/16 v11, 0x0

    cmp-long v9, v9, v11

    if-nez v9, :cond_4

    .line 144
    :cond_2
    if-nez v4, :cond_0

    .line 145
    invoke-interface {v7}, Landroid/content/SharedPreferences;->edit()Landroid/content/SharedPreferences$Editor;

    move-result-object v3

    .line 146
    .local v3, editor:Landroid/content/SharedPreferences$Editor;
    const-string v9, "PRESET"

    const/4 v9, 0x1

    invoke-interface {v3, v14, v9}, Landroid/content/SharedPreferences$Editor;->putBoolean(Ljava/lang/String;Z)Landroid/content/SharedPreferences$Editor;

    .line 147
    invoke-interface {v3}, Landroid/content/SharedPreferences$Editor;->commit()Z

    .line 148
    const-string v9, "FootprintsProvider"

    const-string v9, "install preset Footprints"

    invoke-static {v13, v9}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    .line 149
    const/4 v5, 0x0

    .line 151
    .local v5, input:Ljava/io/InputStream;
    :try_start_0
    iget-object v9, p0, Lcom/htc/android/footprints/provider/FootprintsProvider$1;->this$0:Lcom/htc/android/footprints/provider/FootprintsProvider;

    #getter for: Lcom/htc/android/footprints/provider/FootprintsProvider;->mContext:Landroid/content/Context;
    invoke-static {v9}, Lcom/htc/android/footprints/provider/FootprintsProvider;->access$000(Lcom/htc/android/footprints/provider/FootprintsProvider;)Landroid/content/Context;

    move-result-object v9

    invoke-virtual {v9}, Landroid/content/Context;->getAssets()Landroid/content/res/AssetManager;

    move-result-object v9

    const-string v10, "preset.kmz"

    invoke-virtual {v9, v10}, Landroid/content/res/AssetManager;->open(Ljava/lang/String;)Ljava/io/InputStream;

    move-result-object v5

    .line 152
    invoke-static {v5}, Lcom/htc/android/footprints/kml/KMLUtil;->importKMZ(Ljava/io/InputStream;)[Lcom/htc/android/footprints/vo/Footprint;

    move-result-object v8

    .line 153
    .local v8, presetFootprint:[Lcom/htc/android/footprints/vo/Footprint;
    iget-object v9, p0, Lcom/htc/android/footprints/provider/FootprintsProvider$1;->this$0:Lcom/htc/android/footprints/provider/FootprintsProvider;

    #getter for: Lcom/htc/android/footprints/provider/FootprintsProvider;->mContext:Landroid/content/Context;
    invoke-static {v9}, Lcom/htc/android/footprints/provider/FootprintsProvider;->access$000(Lcom/htc/android/footprints/provider/FootprintsProvider;)Landroid/content/Context;

    move-result-object v9

    invoke-static {v9}, Lcom/htc/android/footprints/provider/FootprintManager;->getInstance(Landroid/content/Context;)Lcom/htc/android/footprints/provider/FootprintManager;

    move-result-object v9

    invoke-virtual {v9, v8}, Lcom/htc/android/footprints/provider/FootprintManager;->addFootprint([Lcom/htc/android/footprints/vo/Footprint;)V
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0
    .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_1

    .line 157
    if-eqz v5, :cond_0

    .line 159
    :try_start_1
    invoke-virtual {v5}, Ljava/io/InputStream;->close()V
    :try_end_1
    .catch Ljava/io/IOException; {:try_start_1 .. :try_end_1} :catch_0

    goto :goto_0

    .line 160
    :catch_0
    move-exception v2

    .line 161
    .local v2, e:Ljava/io/IOException;
    const-string v9, "FootprintsProvider"

    invoke-virtual {v2}, Ljava/io/IOException;->getMessage()Ljava/lang/String;

    move-result-object v9

    invoke-static {v13, v9, v2}, Landroid/util/Log;->w(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I

    goto :goto_0

    .line 154
    .end local v2           #e:Ljava/io/IOException;
    .end local v8           #presetFootprint:[Lcom/htc/android/footprints/vo/Footprint;
    :catch_1
    move-exception v9

    move-object v2, v9

    .line 155
    .restart local v2       #e:Ljava/io/IOException;
    :try_start_2
    const-string v9, "FootprintsProvider"

    invoke-virtual {v2}, Ljava/io/IOException;->getMessage()Ljava/lang/String;

    move-result-object v10

    invoke-static {v9, v10, v2}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I
    :try_end_2
    .catchall {:try_start_2 .. :try_end_2} :catchall_0

    .line 157
    if-eqz v5, :cond_0

    .line 159
    :try_start_3
    invoke-virtual {v5}, Ljava/io/InputStream;->close()V
    :try_end_3
    .catch Ljava/io/IOException; {:try_start_3 .. :try_end_3} :catch_2

    goto :goto_0

    .line 160
    :catch_2
    move-exception v2

    .line 161
    const-string v9, "FootprintsProvider"

    invoke-virtual {v2}, Ljava/io/IOException;->getMessage()Ljava/lang/String;

    move-result-object v9

    invoke-static {v13, v9, v2}, Landroid/util/Log;->w(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I

    goto :goto_0

    .line 157
    .end local v2           #e:Ljava/io/IOException;
    :catchall_0
    move-exception v9

    if-eqz v5, :cond_3

    .line 159
    :try_start_4
    invoke-virtual {v5}, Ljava/io/InputStream;->close()V
    :try_end_4
    .catch Ljava/io/IOException; {:try_start_4 .. :try_end_4} :catch_3

    .line 162
    :cond_3
    :goto_1
    throw v9

    .line 160
    :catch_3
    move-exception v2

    .line 161
    .restart local v2       #e:Ljava/io/IOException;
    const-string v10, "FootprintsProvider"

    invoke-virtual {v2}, Ljava/io/IOException;->getMessage()Ljava/lang/String;

    move-result-object v10

    invoke-static {v13, v10, v2}, Landroid/util/Log;->w(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I

    goto :goto_1

    .line 171
    .end local v2           #e:Ljava/io/IOException;
    .end local v3           #editor:Landroid/content/SharedPreferences$Editor;
    .end local v5           #input:Ljava/io/InputStream;
    :cond_4
    const/16 v9, 0x24

    invoke-static {}, Lcom/htc/android/footprints/utils/FootprintUtils;->getExtDBVersion()I

    move-result v10

    if-ne v9, v10, :cond_0

    .line 172
    iget-object v9, p0, Lcom/htc/android/footprints/provider/FootprintsProvider$1;->this$0:Lcom/htc/android/footprints/provider/FootprintsProvider;

    #getter for: Lcom/htc/android/footprints/provider/FootprintsProvider;->mContext:Landroid/content/Context;
    invoke-static {v9}, Lcom/htc/android/footprints/provider/FootprintsProvider;->access$000(Lcom/htc/android/footprints/provider/FootprintsProvider;)Landroid/content/Context;

    move-result-object v9

    const-string v10, "footprints.db"

    invoke-virtual {v9, v10}, Landroid/content/Context;->getDatabasePath(Ljava/lang/String;)Ljava/io/File;

    move-result-object v0

    .line 174
    .local v0, dbFile:Ljava/io/File;
    invoke-static {v1, v0}, Lcom/htc/android/footprints/utils/FootprintUtils;->copyFile(Ljava/io/File;Ljava/io/File;)Z

    move-result v6

    .line 175
    .local v6, isSuccess:Z
    if-eqz v6, :cond_0

    .line 176
    iget-object v9, p0, Lcom/htc/android/footprints/provider/FootprintsProvider$1;->this$0:Lcom/htc/android/footprints/provider/FootprintsProvider;

    #getter for: Lcom/htc/android/footprints/provider/FootprintsProvider;->mContext:Landroid/content/Context;
    invoke-static {v9}, Lcom/htc/android/footprints/provider/FootprintsProvider;->access$000(Lcom/htc/android/footprints/provider/FootprintsProvider;)Landroid/content/Context;

    move-result-object v9

    invoke-virtual {v9}, Landroid/content/Context;->getContentResolver()Landroid/content/ContentResolver;

    move-result-object v9

    invoke-static {}, Lcom/htc/android/footprints/provider/FootprintsProvider;->access$100()Landroid/net/Uri;

    move-result-object v10

    const/4 v11, 0x0

    invoke-virtual {v9, v10, v11}, Landroid/content/ContentResolver;->notifyChange(Landroid/net/Uri;Landroid/database/ContentObserver;)V

    goto/16 :goto_0
.end method
